package com.test.springboot.springBootUtils.conf;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;

/**
 * activeMQ的连接配置
 * @author My
 *
 */
@Configuration
public class ActiveMqConf {
	@Value("${spring.activemq.broker-url}")
	private String brokerURL;
	@Value("${spring.activemq.user}")
	private String userName;
	@Value("${spring.activemq.password}")
	private String password;

	/**
	 * 默认的JMS监听工厂
	 * @author huyong
	 * @date 2020年9月2日下午3:10:03
	 * @return
	 * @return DefaultJmsListenerContainerFactory
	 */
	@Bean
	public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
		DefaultJmsListenerContainerFactory listenerContainerFactory = new DefaultJmsListenerContainerFactory();
		ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory(userName, password, brokerURL);
		activeMQConnectionFactory.setMaxThreadPoolSize(10);
		listenerContainerFactory.setConnectionFactory(activeMQConnectionFactory);
		return listenerContainerFactory;
	}

	
	
	
	/**
	 * 判断是Linux系统还是windows 系统
	 * @author huyong
	 * @date 2020年9月2日下午3:20:38
	 * @return void
	 */
	public static void iswindowsOrLinux() {
		String osName = System.getProperty("os.name");
		if(osName.toLowerCase().startsWith("windows")) {
			System.out.println("当前操作系统是 windows");
		}
		if(osName.toLowerCase().startsWith("linux")) {
			System.out.println("当前操作系统是linux");
		}

	}
	public static void main(String[] args) {
		iswindowsOrLinux();
	}
}
